package com.cheng.service;

import com.cheng.dao.ProductMapper;
import com.cheng.pojo.Product;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

public class ProductServiceImpl implements ProductService {

    //service调dao层:组合Dao
    private ProductMapper productMapper;
    public void setProductMapper(ProductMapper productMapper) {
        this.productMapper=productMapper;
    }


    public PageInfo<Product> querymerchantsProduct(int page, int pageSize, String userCode) {
        PageHelper.startPage(page, pageSize);
        List<Product> list = productMapper.querymerchantsProduct(userCode);
        PageInfo<Product> pageInfo = new PageInfo<Product>(list);

        return pageInfo;
    }

    public int deleteProduct(String productcode) {
        return productMapper.deleteProduct(productcode);
    }

    public int addmerchandise(String productcode, String productname, String productdetil, Date qwer, String productpath, String productgo, String touring_party_code, String productdetils, String priductaddress, String userCode, String img01, String img02, String img03, String img04, String img05, String cprice, String aprice,String team_number,String remain_number) {
        return productMapper.addmerchandise(productcode,productname,productdetil,qwer,productpath,productgo,touring_party_code,productdetils,priductaddress,userCode,img01,img02,img03,img04,img05,cprice,aprice,team_number,remain_number);
    }

    @Override
    public PageInfo<Product> queryAllProduct(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Product> list = productMapper.queryAllProduct();
        PageInfo<Product> pageInfo = new PageInfo<Product>(list);

        return pageInfo;
    }

    @Override
    public PageInfo<Product> queryAddressProduct(int page, int pageSize, String priductaddress) {
        PageHelper.startPage(page, pageSize);
        List<Product> list = productMapper.queryAddressProduct(priductaddress);
        PageInfo<Product> pageInfo = new PageInfo<Product>(list);

        return pageInfo;
    }

    @Override
    public Product quryOenProduct(String productcode) {
        return productMapper.quryOenProduct(productcode);
    }

    @Override
    public List<Product> allproduct() {
        return productMapper.allproduct();
    }




    @Override
    public int updateremain_number(String productcode,String Adult_number,String Child_number) {
        return productMapper.updateremain_number(productcode,Adult_number,Child_number);
    }

    @Override
    public int remove_number(String productcode, String adult_number, String child_number) {
        return productMapper.remove_number(productcode,adult_number,child_number);
    }

    @Override
    public List<Product> select(String keyWord) {
        return productMapper.select(keyWord);
    }

    @Override
    public Product detail(String productcode) {
        return productMapper.detail(productcode);
    }


}
